<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <link rel="stylesheet" type="text/css" href="/public/static/h-ui/css/H-ui.min.css" />
</head>
<body>
<article class="cl pd-20">
    <form action="" method="post" class="form form-horizontal" id="">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>分类名称：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" autocomplete="off" value="" placeholder="分类名称" class="input-text" id="class_name">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">上级分类：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <select name="search_type" id="pid" class="input-text">
                    <option value="0">顶级分类</option>
                    {foreach name="class_list" item="v1"}
                    <option value="{$v1['class_id']}">{$v1['name']}</option>
                    {/foreach}
                </select>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>分类排序：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" autocomplete="off" value="0" placeholder="分类排序" class="input-text" id="class_sort">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>列表样式：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="radio" id="radio-1" value="1" checked name="demo-radio">
                <label for="radio-1">图文横排</label>
                <input type="radio" id="radio-2" value="2" name="demo-radio">
                <label for="radio-2">图文竖排</label>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>封面图片：</label>
            <div class="formControls col-xs-8 col-sm-8">
                <p style="height: 165px;width:165px;border: dashed 1px #e5e5e5">
                    <img src="" alt="" id="imgarticle_pic" class="thumbnail">
                </p>
                <div style="position: absolute;top:50px;left:200px;color: #ccc;">图片尺寸根据文章列表样式而定<br>
                    图文横排-建议图片尺寸：200*200px<br>
                    图文竖排-建议图片尺寸：600*300px
                </div>
                <div class="upload-btn">
				<span>
					<input type="hidden" value="" id="brand_pic"/>
				</span>
                    <!--<input class="btn radius btn-primary" onclick="on_upload()" type="button" value="上传图片">-->
                    <input onclick="select_img('1','zhu');" class="btn btn-default" type="button" value="选择图片">
                </div>
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3" style="margin-top: 50px;">
                <input class="btn btn-primary radius" onclick="addSuppAjax()" type="button" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
            </div>
        </div>
    </form>
</article>
<script type="text/javascript" src="/public/js/jquery-2.1.1.js"></script>
<script type="text/javascript" src="/public/static/layer/2.4/layer.js"></script>
<script src="/public/js/ajax_file_upload.js" type="text/javascript"></script>
<script src="/public/js/file_upload.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="/public/css/defau.css">
<script src="/public/menu/js/jquery.artdialog.js"></script>
<script src="/public/menu/js/iframetools.js"></script>
<script type="text/javascript">
    function on_upload() {
        $("#uploadImg").trigger("click");
    }
    //模块输入信息验证
    function verify() {
        var class_name = $("#class_name").val();
        var class_sort = $("#class_sort").val();
        var brand_pic=$("#brand_pic").val();
        if (class_name == '') {
            layer.msg('名称不能为空',{icon:5,time:1000});
            return false;
        }
        if (class_sort == '') {
            layer.msg('排序不能为空',{icon:5,time:1000});
            return false;
        }
        if (brand_pic == '') {
            layer.msg('图片不能为空',{icon:5,time:1000});
            return false;
        }
        return true;
    }
    var flag = false;//防止重复提交
    function addSuppAjax() {
        var class_name = $("#class_name").val();
        var class_sort = $("#class_sort").val();
        var brand_pic=$("#brand_pic").val();
        var pid=$("#pid").val();
        var this_radio=$('input:radio:checked').val();
        if(verify() && !flag){
            flag = true;
            $.ajax({
                type : "post",
                url : "__CONF_SITE__admin/article/add_article_class",
                data : {
                    'class_name':class_name,
                    'class_sort' : class_sort,
                    'brand_pic' : brand_pic,
                    'this_radio':this_radio,
                    'pid':pid
                },
                success : function(data) {
                    if(data['code']>0){
                        layer.msg('添加成功!',{icon:1,time:1000},function () {
                            window.parent.location.reload();
                        });
                    }
                    else{
                        flag = false;
                        layer.msg('添加失败',{icon:5,time:1000});
                    }
                }
            });
        }
    }
    function zhu_images(id,path) {
        $("#brand_pic").val(path);
        $("#imgarticle_pic").attr('src',path);
    }
    function select_img(number,type) {
        art.dialog.open(('__CONF_SITE__admin/images/dialogalbumlist&number=' + number + '&type=' + type), {
            lock : true,
            title : "我的图片",
            width : '80%',
            height : '80%',
            drag : false,
            background : "#000000",
            scrollbar:false,
        }, true);
    }
    //图片上传
/*
    function imgUpload(event) {
        var fileid = $(event).attr("id");
        var str = $(event).next().attr("id");
        var data = { 'file_path' : "article_class/" };
        uploadFile(fileid,data,function(res){
            if(res.code){
                $("#img"+str).attr("src",res.data);
                $("#"+str).val(res.data);
                layer.msg(res.message,{icon:1,time:1000});
            }else{
                layer.msg(res.message,{icon:1,time:1000});
            }
        });
    }
*/
</script>
</body>
</html>